body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    background-color: #f0f0f0;
    box-sizing: border-box;
}

#input-container {
    margin-bottom: 30px;
    display: flex;
    width: 100%;
    max-width: 800px;
}

#voice-settings {
    width: 100%;
    max-width: 800px;
    margin: 0 auto 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.setting-group {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.setting-group label {
    width: 100px;
    font-weight: bold;
}

.setting-group select,
.setting-group input[type="range"] {
    flex: 1;
    margin-right: 10px;
}

#voice-select {
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

#rate-value,
#pitch-value {
    width: 30px;
    text-align: center;
}

#new-word {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    margin-right: 5px;
}

#submit-btn {
    padding: 10px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.upload-btn {
    padding: 10px 15px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-right: 5px;
}

#voice-input-btn {
    padding: 10px 15px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-right: 5px;
}

#voice-input-btn:hover {
    background-color: #218838;
}

#voice-input-btn.listening {
    background-color: #dc3545;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        opacity: 1;
    }
}

#submit-btn:hover {
    background-color: #0056b3;
}

#card-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 350px;
    perspective: 1000px;
    margin: 0 auto;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
}

.card.flipped {
    transform: rotateY(180deg);
}

.front, .back {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background-color: white;
    padding: 20px;
    box-sizing: border-box;
}

.back {
    transform: rotateY(180deg);
}

.content, .translation {
    font-size: 32px;
    text-align: center;
    word-break: break-word;
    max-width: 100%;
}

.play-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.delete-btn {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background-color: #dc3545;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.shuffle-btn {
    position: absolute;
    bottom: 10px;
    left: 56px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background-color: #ffc107;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover .play-btn,
.card:hover .delete-btn,
.card:hover .shuffle-btn {
    opacity: 1;
}

.translation {
    position: relative;
    display: inline-block;
}

/* 确保翻转后的卡片始终显示编辑按钮 */
.card.flipped .edit-btn {
    opacity: 0.7;
}

.edit-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background-color: #28a745;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.7; /* 默认显示编辑按钮 */
    transition: opacity 0.3s ease;
    z-index: 10;
    font-size: 20px; /* 增大图标尺寸 */
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* 移除了编辑按钮的hover显示逻辑，使其始终可见 */

/* 确保在触摸设备上也能显示编辑按钮 */
@media (hover: none), (pointer: coarse) {
    .edit-btn {
        opacity: 0.7;
    }
    
    /* 在移动设备上增加点击区域 */
    .translation {
        padding: 10px;
    }
}

/* 当翻译为空时，编辑按钮显示在中央 */
.back.empty-translation .translation .edit-btn {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 1;
}

.prev-btn, .next-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.prev-btn {
    left: 10px;
}

.next-btn {
    right: 10px;
}

.prev-btn:hover, .next-btn:hover, .play-btn:hover, .delete-btn:hover, .shuffle-btn:hover, .edit-btn:hover {
    opacity: 1;
}

/* 响应式设计 - 媒体查询 */
@media screen and (max-width: 768px) {
    #input-container {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    #new-word {
        flex: 1 1 100%;
        margin-bottom: 10px;
        margin-right: 0;
    }
    
    #voice-input-btn, #submit-btn {
        flex: 1;
    }
    
    .card {
        width: 100%;
    }
    
    .content, .translation {
        font-size: 28px;
    }
}

@media screen and (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    #card-container {
        height: 250px;
    }
    
    .content, .translation {
        font-size: 24px;
    }
    
    .play-btn, .delete-btn, .shuffle-btn, .edit-btn {
        opacity: 0.7; /* 在移动设备上始终显示按钮 */
    }
}

/* 错误提示样式 */
.error-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 10px 20px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    animation: slide-down 0.3s ease-out;
}

/* 信息提示样式 */
.info-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    padding: 10px 20px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    animation: slide-down 0.3s ease-out;
}

/* 提示消失动画 */
.fade-out {
    animation: fade-out 0.5s ease-out forwards;
}

@keyframes slide-down {
    from {
        transform: translate(-50%, -20px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}